package com.hhs.storage.bean;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.hhs.storage.util.SysUtil;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.io.Serializable;

/**
 * <p>
 *
 * </p>
 *
 * @author hhs
 * @since 2023-01-06
 */
@Data
public class BusinessOrder implements Serializable {

    private static final long serialVersionUID = 1L;
    public static final int STATUS_CREATE = 0;//待完成
    public static final int STATUS_WORKED = 1;//完成中
    public static final int STATUS_COMPLETE = 2;//已完成
    private String id;

    /**
     * 业务单据id
     */
    private String businessDocumentId;
    @TableField(exist = false)
    private BusinessDocument businessDocument;

    /**
     * 车队id
     */
    private String carfleetId;
    @TableField(exist = false)
    private CarFleet carFleet;
    /**
     * 数量
     */
    private BigDecimal num;
    /**
     * 剩余数量
     */
    private BigDecimal lastNum;

    /**
     * 状态 0待完成，1完成中，2已完成
     */
    private Integer state;

    /**
     * 创建者
     */
    private String creator;

    /**
     * 创建时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    private String startPlace;
    @TableField(exist = false)
    private Region startRegion;
    private String endPlace;
    @TableField(exist = false)
    private Region endRegion;

    private String midPlace;

    public String getStateName() {
        return SysUtil.BUSINESS_ORDER_STATE_MAP.get(this.state);
    }

}
